﻿package bdz.projects.lavender.doi.ui
{
	import bdz.common.events.*;
	import bdz.common.managers.*;
	import bdz.common.model.*;
	import bdz.common.utils.*;
	import bdz.projects.lavender.doi.model.DOIShellReader;
	import bdz.projects.lavender.doi.utils.*;
	import flash.ui.ContextMenu;
	
	import com.asual.swfaddress.SWFAddress;
	import com.asual.swfaddress.SWFAddressEvent;
	
	import gs.*;
	import gs.easing.*;
	
	import flash.events.TimerEvent;
	import flash.net.LocalConnection;
	import flash.display.*;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.media.Video;
	import flash.utils.*;
	import flash.external.*;
	
	import flash.text.*;
	
	
	import com.google.analytics.AnalyticsTracker; 
	import com.google.analytics.GATracker; 
	/**
	 * ...
	 * @author ...
	 */
	public class DOIMain extends MovieClip 
	{
		private var _config:Object;
		private var _env:AppEnvironment;
		private var _planesView:DOIPlanesView;
		private var _quickMenu:DOIQuickMenu;
		private var _quickMenuTrigger:MovieClip;
		private var _reader:DOIShellReader;
		private var _localdata:Array;
		private var _footer:MovieClip;
		private var _videoLayer:Video;
		private var _nsmanager:NetStreamManager;
		
		private var _tracked30:Boolean = false;
		private var _tracked60:Boolean = false;
		private var _trackedEnd:Boolean = false;
		private var _tracked1:Boolean = false;
		private var _viewwidth:Number = 1024;
		private var _viewheight:Number = 750;
		
		private var _cuePoints:CuePointManager;
		private var _onvideo:Boolean = false;
		
		
		private var _onintro:Boolean = false;
		public var _currentvid:String;
		private var _cat4backed:Boolean = false;
		
		private var _lastresolved:String;
		private var _audioOn:Boolean = true;
		private var _audio:DOIAudio;
		private var _tracker:GATracker;
		private var _trackID:String = "UA-10354264-1";
		
		private var _videoRender:DOIVideo;
		
		private var _renderVideo:Boolean = false;
		public function DOIMain() {
			addEventListener(Event.ADDED_TO_STAGE, initializeSite);
			
		}
		private function organizeStage():void {
			var cm:ContextMenu = new ContextMenu();
			cm.hideBuiltInItems();
			this.contextMenu = cm;
			stage.quality = StageQuality.HIGH;
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.addEventListener(Event.RESIZE, onStageResize);
			DispatchChannel.getChannel().addEventListener("moduleTest", addToStage);

		}
		private function addToStage(evt:GenericEvent):void {
			addChild(evt.data);
		}
		private function debugSkip(evt:*=null):void {
			
			skipIntro();
			stage.removeEventListener(MouseEvent.CLICK, debugSkip);
		}
		private function onStageResize(evt:Event = null):void {
			_planesView.x = Math.ceil(stage.stageWidth / 2) - _viewwidth/2;
			_planesView.y = Math.ceil(stage.stageHeight / 2) - _viewheight / 2;
			_planesView.onStageResize(evt);
			if(_currentvid){
				handleVideoAlignment();
			}
			
		}
		private function handleVideoAlignment():void {
			var dx:Number;
			var dy:Number;
			if (_currentvid.indexOf("INTRO") != -1) {
			
				try {
					dx = Math.floor((stage.stageWidth / 2) - (1024 / 2)) - 250;
					dy = Math.floor((stage.stageHeight / 2) - (576 / 2)) + 80;
				}catch (e:Error) { }
			}
			if (_currentvid.indexOf("Category1.flv") != -1) {
				
				try {
					dx = Math.floor((stage.stageWidth / 2) - (1024 / 2)) - 50;
					dy = Math.floor((stage.stageHeight / 2) - (576/2))+50;
				}catch (e:Error) { }
			}
			if (_currentvid.indexOf("Category3.flv") != -1) {
				try {
					dx = Math.floor((stage.stageWidth / 2) - (1024/2))-150;
					dy = Math.floor((stage.stageHeight / 2) - (576/2))+30;
				}catch (e:Error) { }
			}
			if (_currentvid.indexOf("Category4.flv") != -1) {
				try {
					dx = Math.floor((stage.stageWidth / 2) - (1024 / 2)) + 180;
					if (_cat4backed) {
						dy = Math.floor((stage.stageHeight / 2) - (576 / 2)) + 72;
					}else {
						dy = Math.floor((stage.stageHeight) - 600);
					}
				}catch(e:Error){}
			}
			if (_currentvid.indexOf("Category2.flv") != -1) {
				try {
					dx = Math.floor((stage.stageWidth / 2) - (1024 / 2))+70;
					dy = Math.floor((stage.stageHeight / 2) - (576 / 2)) + 80;
				}catch(e:Error){}
			}
			try {
				_videoLayer.x = dx;
				_videoLayer.y = dy;
			}catch (e:Error){}
			try {
				_videoRender.position = { x:dx, y:dy };
			}catch (e:Error){}
			
		}
		private function timerTicks(evt:GenericEvent):void {
			_planesView.render();	
		}
		private function onGlobalValuesLoaded(gl:Object):void {
			dispatchEvent(new GenericEvent("mainLoadProgress", .1));
			_cuePoints.applyCompareList(gl.caption);
			createIntroLayer(gl.homevid, true, 1024, 576);
			GlobalRender.getInstance().addEventListener(GenericEvent.PROGRESS, timerTicks);
		}
		private function createIntroView():void {
			_onintro = true;
			_reader.getGlobalValues(onGlobalValuesLoaded);
		}
		private function initializeSiteUI():void {
			
			
			addChild(_quickMenuTrigger);
			addChild(_quickMenu);
			
			_quickMenu.renderer = "qmenuitem";
			_quickMenu.dataProvider = _localdata;
			
			_planesView.createNavigationView(_localdata, "NavItem");
			
		}
		private function initializeSite(evt:Event):void {
			if(_renderVideo){
				_videoRender = new DOIVideo();
				addChild(_videoRender);
			}
			
			TweenMax.to(mainbg, 1, { alpha:1, ease:Strong.easeInOut } );
		    
			try{
				_tracker = new GATracker( this, _trackID, "AS3", false );
			}catch (e:Error) {
			}
			
			organizeStage();
			
			
			_audio = DOIAudio.getInstance();
			
			
			_cuePoints = CuePointManager.getInstance();
			_cuePoints.addEventListener(GenericEvent.TRIGGER_MATCHED, onCuePointMatched);
			_cuePoints.timeProperty = "rmarkertime";
			
			_env = AppEnvironment.getEnv();
			_env.addSetting("application", this);
			
			
			_env.addSetting("DEMO_MODE", false);
			if(_env.getSetting("baseURL") == null){
				_env.addSetting("baseURL", loaderInfo.parameters.baseURL || "http://info.westpac.com.au/discover_inter/api/");
				
			}
			_env.addSetting("trackID", _trackID);
			
			//_env.addSetting("baseURL", "");
			_config = new Object();
			_config.baseURL = _env.getSetting("baseURL");	
			
			
			_planesView = new DOIPlanesView(_viewwidth, _viewheight, false, true, "Free");
			_planesView.addEventListener("MainNavClicked", onMainNavigationClick);
			_planesView.addEventListener("CatPlaneClicked", onCategoryPlaneClick);
			_planesView.addEventListener("PlaneStateChange", onPlaneStateChange);
			_planesView.addEventListener("BackToCategory", onBackToCategory);
			_planesView.addEventListener("CancelPreloader", onCancelPreloader);
			_planesView.addEventListener("SkipVideo", onSkipVideo);
			_planesView.addEventListener("ReplayCatVideo", onReplayCatVideo);
			_planesView.addEventListener("ContentChanged", onContentChanged);
			_planesView.addEventListener("ResolveDeepLink", onDeepLinkResolve);
			
			addChild(_planesView);
			
			
			_quickMenuTrigger = new QuickMenuBase(); //library item
			_quickMenu = new QuickMenu() as DOIQuickMenu;
			_quickMenuTrigger.x = 30;
			_quickMenu.x = 30;
			_quickMenu.addEventListener("hiding", onQuickMenuHide);
			_quickMenu.addEventListener(GenericEvent.CLICKED, onQuickMenuClicked);
			
			
			_reader = DOIShellReader.getReader(_config);
			
			_quickMenuTrigger.useHandCursor = _quickMenuTrigger.buttonMode = true;
			_quickMenuTrigger.addEventListener(MouseEvent.ROLL_OVER, showQuickMenu);
			_quickMenu.y = _quickMenuTrigger.y + _quickMenuTrigger.height;
			
			
			_reader.getAll(onInitialDataLoad);
			
			_footer = new FooterClip();
			_footer.y = stage.stageHeight + 20;
			addChild(_footer);
			
			onStageResize();
			
			//global channels
			
			DispatchChannel.getChannel().addEventListener("soundIsOff", onSoundOnOff);
			
			setChildIndex(dimmer, numChildren - 1);
			
		}
		private function onDeepLinkResolve(evt:GenericEvent):void {
			_planesView.removeEventListener("ResolveDeepLink", onDeepLinkResolve);
			_onintro = false;
			resolveActiveData(evt.data);
			_planesView._queuedShortcut = null;
		}
		private function onContentChanged(evt:GenericEvent):void {
			
			dispatchEvent(new GenericEvent("ContentChanged", evt.data));
		}
		
		private function skipIntro():void {
			_onintro = false;
			_onvideo = false;
			cleanUpVideoLayer();
			_planesView.killIntroPlane();
			_planesView.destroySkipper();
			_cuePoints.dispatchClearCues();
			initializeSiteUI();
		}
		private function onReplayCatVideo(evt:GenericEvent):void {
			_planesView.destroyReplay();
			_planesView.categoryPlane.baseMovie.refresh();
			_planesView.createSkipper(new Skipper(), -30);
			_onvideo = true;
			handleReplayVideo(evt.data);
		}
		private function onSkipVideo(evt:GenericEvent):void {
			if (_onintro) {
				skipIntro();
				return;
			}
			doTracking(0, false, true);
			_planesView.destroySkipper();
			_planesView.createReplay(new Replay(), -30);
			skipRubbish();
		}

		private function onCancelPreloader(evt:GenericEvent):void {
			
			_planesView.destroyPreloader();
			skipVideoLoading();
		}
		private function onBackToCategory(evt:GenericEvent):void {
			
			if (!evt.data.played) {
				handleVideoFunctions(evt.data.obj, false, true);
			}
		}
		private function onPlaneStateChange(evt:GenericEvent = null):void {
			
			_cuePoints.dispatchClearCues();
			_planesView.destroySkipper();
			_planesView.destroyPreloader();
			_planesView.destroyReplay();
			cleanUpVideoLayer();
			
			
		}
		private function onStreamPlayComplete(evt:NetStreamManagerEvent):void {
			
			if(!_onintro){
				try{
					_planesView.destroySkipper();
					_planesView.createReplay(new Replay(), -30);
				}catch (e:Error) {
					
				}
				doTracking(0, true);
				setTimeout(_cuePoints.dispatchClearCues, 400);
			}
			if (_onintro) {
				
				doTracking(0, true);
				_onintro = false;
				_onvideo = false;
				_cuePoints.dispatchClearCues();
				
			}
			if (_renderVideo) {
				_videoRender.fadeOut();
			}else{
				TweenMax.to(_videoLayer, .6, { alpha:0, ease:Strong.easeOut, onComplete:cleanUpVideoLayer } );
			}
			
			
		}
		private function onStreamCuePoint(evt:NetStreamManagerEvent):void {
			
			_cat4backed = true;
			onStageResize();
			
		}
		private function doTracking(val:*, ended:Boolean = false, skipped:Boolean = false):void {
			var keyword:String;
			if (_currentvid.indexOf("INTRO") != -1) {
				keyword = "Introduction";
			}
			if (_currentvid.indexOf("Category1") != -1) {
				keyword = "Getting Started";
			}
			if (_currentvid.indexOf("Category2") != -1) {
				keyword = "Take control of your money";
			}
			if (_currentvid.indexOf("Category3") != -1) {
				keyword = "Managing your business";
			}
			if (_currentvid.indexOf("Category4") != -1) {
				keyword = "Security and privacy";
			}
			if (skipped) {
				_tracker.trackEvent("Video", keyword + " : Skipped");
			}
			if (ended) {
				if (!_trackedEnd) {
					_trackedEnd = true;
					_tracker.trackEvent("Video", keyword + " : Played End");
					
				}
			}
			if (Math.ceil(val) >= 1) {
				if (!_tracked1) {
					_tracked1 = true;
					_tracker.trackEvent("Video", keyword + "Played 1");
					trace(keyword + " tracking 1");
				}
			}
			if (Math.ceil(val) >= 30) {
				if (!_tracked30) {
					_tracked30 = true;
					_tracker.trackEvent("Video", keyword + "Played 30");
					trace(keyword + " tracking 3+0");
				}
			}
			if (Math.ceil(val) >= 60) {
				if (!_tracked60) {
					_tracked60 = true;
					_tracker.trackEvent("Video", keyword + "Played 60");
					trace(keyword + " tracking 60");
				}
			}
			
		}
		private function onStreamPlayProgress(evt:NetStreamManagerEvent):void {
			
			doTracking(evt.data.position);	
			_cuePoints.analyzeTime(evt.data.position * 1000);
		}
		private function onStreamLoadProgress(evt:NetStreamManagerEvent):void {
			if (_onintro) {
				
				dispatchEvent(new GenericEvent("mainLoadProgress", .1 + (evt.data.percent*.2)));
			}
			_planesView.setPreloaderValue(evt.data.percent);
		}
		private function onStreamLoadComplete(evt:NetStreamManagerEvent):void {
			
			try {
				_onvideo = true;
				
				if (!_onintro) {
					_nsmanager.play();
					//trace("not intro");
					_planesView.destroyPreloader();
					_planesView.createSkipper(new Skipper(), -30 );
					try{
						_planesView.categoryPlane.introPlayed = true;
					}catch (e:Error) {
				
					}
				}else {
					
					if (parent is Stage) {
						//trace("intro");
						_nsmanager.play();
						_planesView.destroyPreloader();
						
						
					}else {
						
					}
					dispatchEvent(new GenericEvent("mainLoadProgress", .3));
					dispatchEvent(new GenericEvent(GenericEvent.COMPLETE));
				}
			}catch (e:Error) {
				trace(e.message);
			}
		}
		public function playFromPreloader():void {
			try{
				_nsmanager.play();
				_planesView.destroyPreloader();
				
			}catch (e:Error) {
				
			}
		}
		private function createStandardElements():void {
			//_audio.playAmbient();
			_footer.show();
			//_logo.show();
			
			
		}
		private function resolveIntroCuePoints(val:*):void {
			
			if (val is Number) {
				switch(val) {
					case 0:
						
						TweenMax.to(dimmer, 1, { alpha:0, ease:Strong.easeInOut, onComplete:function() { dimmer.visible = false;} } );
						createStandardElements();
						
					break;
					case 1:
						//_planesView.introPlane.moveToStandard();
						_planesView.createIntroPlane();
						_planesView.createSkipper(new Skipper(), -30, -10, 80);
					break;
					case 2:
						_planesView.killIntroPlane();
						_planesView.destroySkipper();
					break;
					case 3:
						initializeSiteUI();
					break;
				}
			}else {
				_planesView.introPlane.createMovie(val);
			}
			
		}
		private function onCuePointMatched(evt:GenericEvent):void {
			
			var capstring:String;
			if (_onvideo) {
				if(evt.data.captionvalue){
					capstring = evt.data.captionvalue;
					if (capstring.indexOf("NavTrigger") != -1) {
						var tindex:Number = Number(capstring.split(":")[1]);
						_onintro ? resolveIntroCuePoints(tindex) : _planesView.triggerCategoryNav(tindex);
					}
					if (capstring.indexOf("AnimationTrigger") != -1) {
						var linkage:String = capstring.split(":")[1];
						_onintro ? resolveIntroCuePoints(linkage) : _planesView.showCategoryAnimation(linkage);
					}
				}
			}
		}
		private function resolveCaptionObject(xlist:XMLList):Array {
			var arr:Array = new Array();
			for each(var xm:XML in xlist) {
				var o = { };
				var chl:XMLList = xm.children();
				for each(var xc:XML in chl) {
					o[xc.name()] = Number(xc.toString()) ? Number(xc.toString()) : xc.toString();
				}
				arr.push(o);
			}
			return arr;
		}
		
		private function onCategoryPlaneClick(evt:GenericEvent):void {
			_onvideo = false;
			
			resolveActiveData(evt.data, true);
		}
		private function handleReplayVideo(obj:Object):void {
			_cuePoints.applyCompareList(resolveCaptionObject(new XMLList(obj.definition.toString())[0].caption));
			createVideoLayer(obj.swfimage, true);
		}
		private function handleVideoFunctions(obj:Object, createnew:Boolean = false, backed:Boolean = false):void {
				_tracked1 = false;
				_trackedEnd = false;
				_tracked30 = false;
				_tracked60 = false;
				cleanUpVideoLayer();
				var hasvideo:Boolean = obj.swfimage != "";
				if (!backed) {
					if (createnew) {			
						_planesView.destroySkipperReplay();
						_planesView.showNewCategory(obj, "CatViewBG", !hasvideo);
					}else {
						_planesView.destroySkipperReplay();
						_planesView.createCategoryPlane(obj, "CatViewBG", !hasvideo);
					}
				
				}
				if (hasvideo) {
					createVideoLayer(obj.swfimage);
				}
			
			_cuePoints.applyCompareList(resolveCaptionObject(new XMLList(obj.definition.toString())[0].caption));
		}
		private function finalizeSkipRubbish():void {
			cleanUpVideoLayer();
			if (_planesView.categoryPlane.z == 0) {
				_cuePoints.dispatchClearCues();
				_planesView.categoryPlane.introPlayed = true;
				_planesView.categoryPlane.showAllMenu();
			}
		}
		private function skipRubbish():void {
			if (_renderVideo) {
				_videoRender.fadeOut();
			}else{
				TweenMax.to(_videoLayer, .8, { alpha:0, ease:Strong.easeOut, onComplete:finalizeSkipRubbish } );
			}
			
		}
		private function skipVideoLoading():void {
			
			cleanUpVideoLayer();
			if (_planesView.categoryPlane.z == 0) {
				_planesView.categoryPlane.showAllMenu();
			}
		}
		private function onMainNavigationClick(evt:GenericEvent):void {
			//handleVideoFunctions(evt.data);
			if (_onintro) {
				_onintro = false;
				_onvideo = false;
			}
			//trace("changing content >>" + evt.data);
			dispatchEvent(new GenericEvent("ContentChanged", evt.data));
			resolveActiveData(evt.data);
		}
		private function onSoundOnOff(evt:GenericEvent):void {
			
			if (evt.data) {
				_audio.turnOn();
				try {
					_nsmanager.volume = 1;
				}catch (e:Error){}
			}else {
				_audio.turnOff();
				try {
					_nsmanager.volume = 0;
				}catch (e:Error){}
			}
			
			_audioOn = evt.data;
		}
		
		private function cleanUpVideoLayer():void {
			_trackedEnd = false;
			_tracked30 = false;
			_tracked60 = false;
			_onvideo = false;
			_planesView.stopCategoryAnimation();
			try{
				_videoLayer.clear();
			}catch (e:Error) { }
			try {
				_nsmanager.removeEventListener(NetStreamManagerEvent.LOAD_COMPLETE, onStreamLoadComplete);
				_nsmanager.removeEventListener(NetStreamManagerEvent.PLAY_PROGRESS, onStreamPlayProgress);
				_nsmanager.removeEventListener(NetStreamManagerEvent.PLAY_COMPLETE, onStreamPlayComplete);
				_nsmanager.removeEventListener(NetStreamManagerEvent.LOAD_PROGRESS, onStreamLoadProgress);
				_nsmanager.clear();
				_nsmanager = null;
			}catch (e:Error) { }
			try {
				removeChild(_videoLayer);
			}catch (e:Error) { }
			try {
				_videoRender.stopRendering();
			}catch(e:Error){}
			var lc:LocalConnection = new LocalConnection();
			try {
				lc.connect("bogus");
				lc.connect("bogus");
			}catch (e:Error) {
				
			}
			_planesView.destroyPreloader();
			
			//stage.quality = StageQuality.HIGH;
		}
		private function createVideoBase(src:String, autoplay:Boolean = false, w:Number = 720, h:Number = 405):void {
			
			_currentvid = src;
			
			
			if (_currentvid.indexOf("Category4.flv") != -1) { 
				_cat4backed = false;
			}
			//src += "?cacheBuster=" + new Date().getTime();
			
			
			try {
				removeChild(_videoLayer);
			}catch (e:Error) {
				
			}
			
			_videoLayer = new Video(w, h);
			_videoLayer.x = 131;
			_videoLayer.y = 230;
			
			if(_renderVideo){
				_videoRender.renderVideo(_videoLayer);
			}else{
				_videoLayer.smoothing = true;
				addChild(_videoLayer);
			}
			
			
			
			
			onStageResize();
			setChildIndex(_footer, numChildren - 1);
			
			_nsmanager = null;
			
			_nsmanager = new NetStreamManager();
			_nsmanager.volume = _audioOn ? 1 : 0;
			_nsmanager.vsource = _videoLayer;
			_nsmanager.autoPlay = autoplay;
			_nsmanager.refreshRate = 200;
			_nsmanager.loadOffset = .5;
			_nsmanager.source = src;
			_nsmanager.addEventListener(NetStreamManagerEvent.ON_CUEPOINT, onStreamCuePoint);
			_nsmanager.addEventListener(NetStreamManagerEvent.LOAD_PROGRESS, onStreamLoadProgress);
			_nsmanager.addEventListener(NetStreamManagerEvent.LOAD_COMPLETE, onStreamLoadComplete);
			_nsmanager.addEventListener(NetStreamManagerEvent.PLAY_PROGRESS, onStreamPlayProgress);
			_nsmanager.addEventListener(NetStreamManagerEvent.PLAY_COMPLETE, onStreamPlayComplete);
			
			//stage.quality = StageQuality.MEDIUM;
		}
		private function createIntroLayer(src:String, autoplay:Boolean = false, w:Number = 720, h:Number = 405):void {
			
			//src = "http://badongers.com/testzone/INTRO.flv?cacheBuster=" + new Date().getTime();
			_onvideo = true;
			createVideoBase(src, parent is Stage, w, h);
			setChildIndex(dimmer, numChildren - 1);
			
		}
		private function createVideoLayer(src:String, autoplay:Boolean = false, w:Number = 720, h:Number = 405):void {
			createVideoBase(src, autoplay, w, h);
			_planesView.createPreloader(new Preloader(), -30, false);
		}
		
		private function reactivateTrigger():void {
			_quickMenuTrigger.addEventListener(MouseEvent.ROLL_OVER, showQuickMenu);
		}
		public function resolveActiveData(obj:Object, create:Boolean = false, dp:Boolean = false):void {
			if(!dp){
				onPlaneStateChange();
			}
			switch(obj.type){
				case "category":
					handleVideoFunctions(obj, true);
					
				return;
				case "module":
					_onvideo = false;
					if (create) {
						_planesView.createModulePlane(obj, "ModViewFrame");
					}else{
						_planesView.showNewModule(obj);
					}
				break;
				case "chapter":
					_onvideo = false;
					_planesView.showNewChapter(obj);
				break;	
			}
			_planesView.viewport.buttonMode = false;
			
			
			
		}
		public function backToNav(dispatch:Boolean = true):void {
			cleanUpVideoLayer();
			_planesView.goHome(dispatch);
			_cuePoints.dispatchClearCues();
		}
		public function gotoContentWithID(id:String):void {
			dimmer.visible = false;
			var actObj:Object = null;
			for each(var obj:Object in _localdata) {
				if (obj.shortname == id) {
					actObj = obj;
					break;
				}
				if (obj.modules && obj.modules.length) {
					for each(var mobj:Object in obj.modules) {
						if (mobj.shortname == id) {
							actObj = mobj;
							break;
						}
						if (mobj.steps && mobj.steps.length) {
							for each(var sobj:Object in mobj.steps) {
								if (sobj.shortname == id) {
									actObj = sobj;
									break;
								}
							}
						}
					}
				}
			}
			if(_planesView._navCreated){
				if (actObj) {
					if (actObj.type == "category") {
						if (_planesView.categoryPlane && _planesView.categoryPlane.contentObject.shortname == actObj.shortname) {
							_planesView.onCategoryPlaneBack();
						}else {
							//trace("act resolve");
							resolveActiveData(actObj);
						}
					}else {
						//trace("simple resolve");
						resolveActiveData(actObj);
					}
				}
			}else {
				_planesView._queuedShortcut = actObj;
				initializeSiteUI();
				createStandardElements();
			}
		
		}
		private function onQuickMenuClicked(evt:GenericEvent):void {
			//trace("changing content >> " + evt.data);
			dispatchEvent(new GenericEvent("ContentChanged", evt.data));
			resolveActiveData(evt.data);
			
		}
		private function onQuickMenuHide(evt:GenericEvent):void {
			_quickMenuTrigger.removeEventListener(MouseEvent.ROLL_OVER, showQuickMenu);
			_quickMenuTrigger.rollOutAction();
			setTimeout(reactivateTrigger, 500);
		}
		
		private function showQuickMenu(evt:MouseEvent):void {
			_quickMenu.show();
			_quickMenuTrigger.rollOverAction();
		}
		
		private function onInitialDataLoad(arr:Array):void {
			dispatchEvent(new GenericEvent("mainLoadProgress", .05));
			_localdata = arr;
			_env.addSetting("doiInfo", _localdata);
			createIntroView();
			
		}
		
	}
	
}